package com.chang.product.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/*
 * @Author Changzhenxi
 * @Date 2024/3/4 15:23
 * @Description This is description of method
 * @Since version 1.0
 */
@Configuration
@EnableTransactionManagement // 开启事务
public class MybatisConfig {
    // 引入分页插件
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));//如果配置多个插件,切记分页最后添加
        new PaginationInnerInterceptor().setOverflow(true);
        return interceptor;
    }
}
